﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Lavanderia.Entities;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Lavanderia.Repository.Mapping
{
    public class CLIENTE_JURIDICOMap:EntityTypeConfiguration<CLIENTE_JURIDICO>
    {
        public CLIENTE_JURIDICOMap()
        {
            this.Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            //Primary Key
            this.HasKey(t => t.ClienteJuridicoId);

            //Properties
            this.Property(t => t.ClienteJuridicoId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Ruc)
                .IsRequired()
                .HasMaxLength(11);

            this.Property(t => t.RazonSocial)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Encargado)
                .IsOptional()
                .HasMaxLength(50);

            this.Property(t => t.DniEncargado)
                .IsOptional()
                .HasMaxLength(8);

            this.Property(t => t.DireccionEncargado)
                .IsOptional()
                .HasMaxLength(50);

            this.ToTable("CLIENTE_JURIDICO");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.ClienteJuridicoId).HasColumnName("ClienteJuridicoId");
            this.Property(t => t.Ruc).HasColumnName("Ruc");
            this.Property(t => t.RazonSocial).HasColumnName("RazonSocial");
            this.Property(t => t.Encargado).HasColumnName("Encargado");
            this.Property(t => t.DniEncargado).HasColumnName("DniEncargado");
            this.Property(t => t.DireccionEncargado).HasColumnName("DireccionEncargado");

            this.HasRequired(t => t.CLIENTE)
                .WithOptional(t => t.CLIENTE_JURIDICO)
                .WillCascadeOnDelete(false);
        }
    }
}
